/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.clinicplus.manager;

import br.com.foxline.clinicplus.entity.Cbo;
import br.com.foxline.clinicplus.service.CboService;
import br.com.foxline.clinicplus.util.Msg;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author roniere
 */
@ManagedBean
@ViewScoped
public class ManagerCbo implements Serializable {

    @EJB
    CboService cboService;
    private Cbo cbo;

    @PostConstruct
    public void init() {
        this.cbo = new Cbo();
    }

    public List<Cbo> autocomplete(String query) {
        return cboService.findAll();
    }
 
    public void create() {
        try {
            cboService.save(cbo);
            Msg.messagemInfo("Operação realizado com Sucesso");
            init();
         } catch (Exception erro) {
        }
    }

    public Cbo getCbo() {
        return cbo;
    }

    public void setCbo(Cbo cbo) {
        this.cbo = cbo;
    }
}
